﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Janksen.ValidationHelper
{
	/// <summary>
	/// 验证工厂方法类
	/// </summary>
	public static class Validation
	{
        #region 验证工厂方法，初始化验证
        /// <summary>
        /// 验证工厂方法，初始化验证
        /// </summary>
        /// <typeparam name="T">验证的泛型</typeparam>
        /// <param name="value">待验证的参数的值</param>
        /// <returns></returns>
        public static ValidationHelper<T> InitValidation<T>(this T value)
        {
            return new ValidationHelper<T>(value, "", false);
        } 
        #endregion

        #region 验证工厂方法，初始化验证
        /// <summary>
        /// 验证工厂方法，初始化验证
        /// </summary>
        /// <typeparam name="T">验证的泛型</typeparam>
        /// <param name="value">待验证的参数的值</param>
        /// <param name="argName">待验证的参数的名称</param>
        /// <returns></returns>
        public static ValidationHelper<T> InitValidation<T>(this T value, string argName)
        {
            return new ValidationHelper<T>(value, argName, false);
        } 
        #endregion

        #region 验证工厂方法，初始化验证
        /// <summary>
        /// 验证工厂方法，初始化验证
        /// </summary>
        /// <typeparam name="T">验证的泛型</typeparam>
        /// <param name="value">待验证的参数的值</param>
        /// <param name="isThrowException">验证不通过时是否抛出异常</param>
        /// <returns></returns>
        public static ValidationHelper<T> InitValidation<T>(this T value, bool isThrowException)
        {
            return new ValidationHelper<T>(value, "", isThrowException);
        } 
        #endregion

        #region 验证工厂方法，初始化验证
        /// <summary>
        /// 验证工厂方法，初始化验证
        /// </summary>
        /// <typeparam name="T">验证的泛型</typeparam>
        /// <param name="value">待验证的参数的值</param>
        /// <param name="argName">待验证的参数的名称</param>
        /// <param name="isThrowException">验证不通过时是否抛出异常</param>
        /// <returns></returns>
        public static ValidationHelper<T> InitValidation<T>(this T value, string argName, bool isThrowException)
        {
            return new ValidationHelper<T>(value, argName,isThrowException);
        }
        #endregion
	}
}
